using System.Web;
using System;
namespace EasyGrocer.DataLayer
{
    internal static class DataContextContainer
    {
        public static EasyGrocerDBDataContext CurrentDataContext
        {
            get
            {
                if (HttpContext.Current.Items["EasyGrocerDataContext"] == null)
                {
                    HttpContext.Current.Items["EasyGrocerDataContext"]
                        = new EasyGrocerDBDataContext();
                }
                return (EasyGrocerDBDataContext)HttpContext.Current.Items["EasyGrocerDataContext"];
            }
        }
        public static void Submit()
        {
            if (HttpContext.Current.Items["EasyGrocerDataContext"] != null)
            {
                ((EasyGrocerDBDataContext)HttpContext.Current.Items["EasyGrocerDataContext"]).SubmitChanges();
            }
            else
            {
                throw new ArgumentException("null datacontext");
            }
        }
    }
}